/**
 * @param {number[]} gem
 * @param {number[][]} operations
 * @return {number}
 */
 var giveGem = function(gem, operations) {
  for(const [x, y] of operations) {
    const t = Math.floor(gem[x]/2)
    gem[x] -= t
    gem[y] += t
  }
  const max = Math.max(...gem), min = Math.min(...gem)
  return max - min
};